<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Dynamic treeview</title>
<style>
body {
font-family:verdana;
font-size:12px;
}
</style>
</head>
<body leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0" topmargin="0">

<table border="0" width="100" height="100%" cellpadding="0" cellspacing="0">
	<tr id="p0">
		<td id="parent0" valign="top"></td>
	</tr>
</table>


</body>
</html>

<script language="javascript1.3">
var ie= document.all&&document.getElementById;

function showOver(obj){
	obj.style.cursor=(ie)?'hand':'pointer';
	obj.style.backgroundColor='#0B256B';
	obj.style.color='#FFFFFF';
}

function showOut(obj){
	obj.style.backgroundColor='';
	obj.style.color='#000000';
}
</script>

<script language="javascript1.3">
<!--
var cnt=0;
var par="";
var prev;

function showFiles(dir, s_parent) {
	var id = s_parent.replace("parent","");
	
	try { if(prev>0) document.getElementById("map"+prev).src = document.getElementById("map"+prev).src.replace("open","toe"); } catch(e) {} 
	prev = id;
	parent.document.getElementById('wg_Menu').src = "files.php?root=" + dir;
	document.getElementById("map"+id).src = document.getElementById("map"+id).src.replace("toe","open");
}


function importXML(dir, s_parent) {
	try { if(prev>0) document.getElementById("map"+prev).src = document.getElementById("map"+prev).src.replace("open","toe"); } catch(e) {} 
	parent.document.getElementById('wg_Menu').src = "files.php?root=" + dir;
	document.getElementById(s_parent).innerHTML = '<div id="loading" style="color:#999999">Loading...</div>';
	try { 
		var id = s_parent.replace("parent","");
		document.getElementById("img"+id).src = document.getElementById("img"+id).src.replace("plus","minus");
		document.getElementById("map"+id).src = document.getElementById("map"+id).src.replace("toe","open");
	} catch(e) {}
	
	if (document.implementation && document.implementation.createDocument) {
		xmlDoc = document.implementation.createDocument("", "", null);
		par = s_parent;
		xmlDoc.onload = createTable;
	} else if (window.ActiveXObject) {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {
			par = s_parent;
			if (xmlDoc.readyState == 4) createTable()
		};
 	} else {
		alert('Your browser can\'t handle this script');
		return;
	}
	
	xmlDoc.load("Classes/cls_treeview.php?root=" + dir);
}


function createTable() {
	
	var x = xmlDoc.getElementsByTagName('dir');
	var s_parent = par;
	var tmp ="";
	
	if(x.length > 0) {
		tmp += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';

		for (i=0;i<x.length;i++) {
			cnt++;
			
			var name = x[i].getElementsByTagName("name");
			var path = x[i].getElementsByTagName("path");
			var children = x[i].getElementsByTagName("children");
			
			if(children[0].firstChild.nodeValue > 0) {
				tmp += '<tr onmouseover="showOver(this);" onmouseOut="showOut(this);" onclick="importXML(\''+ path[0].firstChild.nodeValue +'\', \'parent'+ cnt +'\');">';
				if(i == x.length-1) {
					var img = '<img id="img'+cnt+'" src="Images/Treeview/lastplus.gif" alt="">';
				} else {
					var img = '<img id="img'+cnt+'" src="Images/Treeview/plus.gif" alt="">';
				}
			} else {
				tmp += '<tr onmouseover="showOver(this);" onmouseOut="showOut(this);" onclick="showFiles(\''+ path[0].firstChild.nodeValue +'\', \'parent'+ cnt +'\');">';
				if(i == x.length -1) {
					var img = '<img id="img'+cnt+'" src="Images/Treeview/lastdots.gif" alt="">';
				} else {
					var img = '<img id="img'+cnt+'" src="Images/Treeview/dots.gif" alt="">';
				}
			}
			
			tmp += '<td width="17">'+img+'</td>';
			tmp += '<td width="20"><img id="map'+cnt+'" src="Images/maptoe.gif" width="17" height="13" alt=""></td>';
			tmp += '<td width="100%" align="left">';
			tmp += '<div style="white-space:nowrap;width:150px;overflow:hidden;text-overflow:ellipsis;height:14px;">&nbsp;'+name[0].firstChild.nodeValue +'</div>';
			tmp += '</td>';
			
			tmp += '</tr>';
			
			
			if(children[0].firstChild.nodeValue > 0) {
				tmp += '<tr>';
				if(x.length > 1 && i != x.length-1) {
					tmp += '<td background="Images/Treeview/blankdots.gif" width="17"></td>';
				} else {
					tmp += '<td background="Images/Treeview/spacer.gif"></td>';
				}

				tmp += '<td colspan="2" id="parent' + cnt + '"></td>';
				tmp += '</tr>';
			} 
			
		}
		
		tmp += '</table>';
	}
	
	document.getElementById(s_parent).innerHTML = tmp;
}

importXML("../", "parent0");
//-->
</script>



